# #####################################################################
# Based on https://github.com/cilium/cilium/blob/v1.14.5/images/operator/Dockerfile
# #####################################################################
---
{{- $ciliumVersion := "1.14.5" }}
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-build-artifact
from: {{ $.Images.BASE_GOLANG_20_ALPINE }}
mount:
- fromPath: ~/go-pkg-cache
  to: /go/pkg
shell:
  beforeInstall:
  - apk add --no-cache make git bash
  install:
  - export GO_VERSION=${GOLANG_VERSION}
  - export GOPROXY={{ $.GOPROXY }}
  - export GOOS=linux GOARCH=amd64
  - mkdir -p /go/src/github.com/cilium/cilium
  - git clone --depth 1 --branch v{{ $ciliumVersion }} {{ $.SOURCE_REPO }}/cilium/cilium.git /go/src/github.com/cilium/cilium
  - cd /go/src/github.com/cilium/cilium
  - make DESTDIR=/out/linux/amd64 build-container-operator install-container-binary-operator
  - chown 64535:64535 /out/linux/amd64/usr/bin/cilium-operator
  - chmod 0700 /out/linux/amd64/usr/bin/cilium-operator
---
image: {{ $.ModuleName }}/{{ $.ImageName }}
fromImage: common/distroless
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-build-artifact
  add: /out/linux/amd64/usr/bin/cilium-operator
  to: /usr/bin/cilium-operator
  before: install
docker:
  USER: 64535
  ENTRYPOINT: ["/usr/bin/cilium-operator"]
